<p>JUnit5 is more tolerant regarding the visibilities of Test classes than JUnit4, which required everything to be <code>public</code>.</p>
<p>In this context, JUnit5 test classes can have any visibility but <code>private</code>, however, it is recommended to use the default package
visibility, which improves readability of code.</p>
<h2>Noncompliant Code Example</h2>
<pre>
import org.junit.jupiter.api.Test;

public class MyClassTest { // Noncompliant - modifier can be removed
  @Test
  protected void test() { // Noncompliant - modifier can be removed
    // ...
  }
}
</pre>
<h2>Compliant Solution</h2>
<pre>
import org.junit.jupiter.api.Test;

class MyClassTest {
  @Test
  void test() {
    // ...
  }
}
</pre>
<h2>Exceptions</h2>
<p>This rule does not raise an issue about <code>private</code> visibility, because <code>private</code> test methods and classes are systematically
ignored by JUnit5, without a proper warning. It’s not a <code>Code Smell</code> but a <code>Bug</code> handled by the rule {rule:java:S5810} .</p>
<h2>See</h2>
<ul>
  <li> <a href="https://junit.org/junit5/docs/current/user-guide/#writing-tests-classes-and-methods">JUnit 5 Test Classes and Methods</a> </li>
</ul>

